package com.cskaoyan.util;

import com.cskaoyan.bean.Admin;
import com.cskaoyan.bean.User;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.subject.Subject;

/**
 * 创建日期: 2022/05/09 21:50
 *
 * @author 孙豪骏
 */
public class GetLogedAdmin {
    //获得认证成功的管理员信息；
    public static Admin getLogedAdmin() {
        Subject subject = SecurityUtils.getSubject();
        if (subject.isAuthenticated()) {
            Admin logedAdmin = (Admin) subject.getPrincipals().getPrimaryPrincipal();
            return logedAdmin;
        }
        return null;
    }

    public static User getLogedUser() {
        Subject subject = SecurityUtils.getSubject();
        if (subject.isAuthenticated()) {
            User logedUser = (User) subject.getPrincipals().getPrimaryPrincipal();
            return logedUser;
        }
        return null;
    }
}